package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.HlsDbDataSourceColumn;
import com.bestow.basic.service.IHlsDbDataSourceColumnService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 数据来源字段Controller
 * 
 * @author liliu
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/basic/dbDataSourceColumn")
public class HlsDbDataSourceColumnController extends BaseController
{
    @Autowired
    private IHlsDbDataSourceColumnService hlsDbDataSourceColumnService;

    /**
     * 查询数据来源字段列表
     */
    @PreAuthorize("@ss.hasPermi('basic:dbDataSourceColumn:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlsDbDataSourceColumn hlsDbDataSourceColumn)
    {
        startPage();
        List<HlsDbDataSourceColumn> list = hlsDbDataSourceColumnService.selectHlsDbDataSourceColumnList(hlsDbDataSourceColumn);
        return getDataTable(list);
    }

    /**
     * 导出数据来源字段列表
     */
    @PreAuthorize("@ss.hasPermi('basic:dbDataSourceColumn:export')")
    @Log(title = "数据来源字段", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlsDbDataSourceColumn hlsDbDataSourceColumn)
    {
        List<HlsDbDataSourceColumn> list = hlsDbDataSourceColumnService.selectHlsDbDataSourceColumnList(hlsDbDataSourceColumn);
        ExcelUtil<HlsDbDataSourceColumn> util = new ExcelUtil<HlsDbDataSourceColumn>(HlsDbDataSourceColumn.class);
        util.exportExcel(response, list, "数据来源字段数据");
    }

    /**
     * 获取数据来源字段详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:dbDataSourceColumn:query')")
    @GetMapping(value = "/{dataSourceColumnId}")
    public AjaxResult getInfo(@PathVariable("dataSourceColumnId") Long dataSourceColumnId)
    {
        return AjaxResult.success(hlsDbDataSourceColumnService.selectHlsDbDataSourceColumnByDataSourceColumnId(dataSourceColumnId));
    }

    /**
     * 新增数据来源字段
     */
    @PreAuthorize("@ss.hasPermi('basic:dbDataSourceColumn:add')")
    @Log(title = "数据来源字段", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlsDbDataSourceColumn hlsDbDataSourceColumn)
    {
        return toAjax(hlsDbDataSourceColumnService.insertHlsDbDataSourceColumn(hlsDbDataSourceColumn));
    }

    /**
     * 修改数据来源字段
     */
    @PreAuthorize("@ss.hasPermi('basic:dbDataSourceColumn:edit')")
    @Log(title = "数据来源字段", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlsDbDataSourceColumn hlsDbDataSourceColumn)
    {
        return toAjax(hlsDbDataSourceColumnService.updateHlsDbDataSourceColumn(hlsDbDataSourceColumn));
    }

    /**
     * 删除数据来源字段
     */
    @PreAuthorize("@ss.hasPermi('basic:dbDataSourceColumn:remove')")
    @Log(title = "数据来源字段", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dataSourceColumnIds}")
    public AjaxResult remove(@PathVariable Long[] dataSourceColumnIds)
    {
        return toAjax(hlsDbDataSourceColumnService.deleteHlsDbDataSourceColumnByDataSourceColumnIds(dataSourceColumnIds));
    }
}
